
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.factory.server.bo;

import com.factory.server.dto.EdgeDTO;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.hibernate.annotations.Index;

/**
 *
 * @author milos
 */
@Entity
@Table(name = "edge")

public class Edge extends AbstractBusinessObject {

    private static final long serialVersionUID = 1L;
    @Column(name = "input_id")
    @Index(name="inputId")
    private String inputId;
    
    @Basic(optional = true)
    @Column(name = "source")
    private Integer source;
    
    @Basic(optional = true)
    @Column(name = "target")
    private Integer target;
    
    @Basic(optional = true)
    @Column(name = "cost")
    private double cost;
    
    @Basic(optional = false)
    @Column(name = "user_id")
    private String userId;

    public Edge() {
    }

    public Edge (String inputId, String userId, EdgeDTO edgeDTO){
         this.inputId = inputId;
        this.source = edgeDTO.getSource();
        this.target = edgeDTO.getTarget();
        this.cost = edgeDTO.getCost();
        this.userId = userId;
    }
    
    public Edge(String inputId, Integer source, Integer target, double cost, String userId) {
        this.inputId = inputId;
        this.source = source;
        this.target = target;
        this.cost = cost;
        this.userId = userId;
    }

    public String getInputId() {
        return inputId;
    }

    public void setInputId(String inputId) {
        this.inputId = inputId;
    }

    public Integer getSource() {
        return source;
    }

    public void setSource(Integer source) {
        this.source = source;
    }

    public Integer getTarget() {
        return target;
    }

    public void setTarget(Integer target) {
        this.target = target;
    }

    public double getCost() {
        return cost;
    }

    public void setCost(double cost) {
        this.cost = cost;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Edge)) {
            return false;
        }
        Edge other = (Edge) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
//        return "com.factory.server.bo.Edge[ id=" + id + " ]";
                return source+" "+target+" "+cost;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }
}
